package mipushdemo.xiaomi.com.diyitonghang.ui.activity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.widget.FrameLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import butterknife.BindView;
import butterknife.ButterKnife;
import mipushdemo.xiaomi.com.diyitonghang.R;
import mipushdemo.xiaomi.com.diyitonghang.base.BaseActivity;
import mipushdemo.xiaomi.com.diyitonghang.ui.fragment.HomeFragment;
import mipushdemo.xiaomi.com.diyitonghang.ui.fragment.HuaFragment;
import mipushdemo.xiaomi.com.diyitonghang.ui.fragment.MineFragment;

public class MainActivity extends BaseActivity implements RadioGroup.OnCheckedChangeListener {
    @BindView(R.id.rb_home)
    RadioButton rbHome;
    @BindView(R.id.rb_hua)
    RadioButton rbHua;
    @BindView(R.id.rb_mine)
    RadioButton rbMine;
    @BindView(R.id.rg)
    RadioGroup rg;
    @BindView(R.id.mFrame)
    FrameLayout mFrame;
    public static String userId;

    @Override
    protected int windowColor() {
        return R.color.colorRed;
    }

    @Override
    protected void init() {
        SharedPreferences preferences = getSharedPreferences("id", MODE_PRIVATE);
        userId = preferences.getString("userId", "");
        setCreateView(R.id.mFrame, HomeFragment.class, null);
        rg.setOnCheckedChangeListener(this);
    }

    @Override
    protected void loadData() {

    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_main;
    }

    @Override
    public void onCheckedChanged(RadioGroup group, int checkedId) {
        switch (checkedId) {
            case R.id.rb_home:
                setCreateView(R.id.mFrame, HomeFragment.class, null);
                break;
            case R.id.rb_hua:
                setCreateView(R.id.mFrame, HuaFragment.class, null);
                break;
            case R.id.rb_mine:
                setCreateView(R.id.mFrame, MineFragment.class, null);
                break;
        }
    }
}
